﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 地图控制器：地图生成，地图块容器。
/// </summary>
public class MapContorller : BaseManager<MapContorller>
{
    /*~~~~~~~~~~~~~~~~~~~~变量区~~~~~~~~~~~~~~~~~~~~~~~~~*/
    /// <summary>
    /// 格子的长度
    /// </summary>
    float gridHorValue;
    /// <summary>
    /// 格子的宽度
    /// </summary>
    float gridVerValue;
    /// <summary>
    /// 地图长边格子的个数
    /// </summary>
    int horizontalValue;
    /// <summary>
    /// 地图宽边格子的个数
    /// </summary>
    int verticalValue;
    /// <summary>
    /// 所有的格子总数
    /// </summary>
    int allGridValue;
    BaseGrid[,] arrayGrid;

    public BaseGrid[,] ArrayGrid { get => arrayGrid; set => arrayGrid = value; }



    /*~~~~~~~~~~~~~~~~~~~~~方法区~~~~~~~~~~~~~~~~~~~~~~~~*/
    /// <summary>
    ///  加载地图配置数据
    /// </summary>
    void LoadMapConfigData()
    {

    }
    /// <summary>
    /// 绘制地图   tag：功能测试，需从配置表中获取参数
    /// </summary>
    public void DrawMap(int hor, int ver, GameObject floor, Material[] material, Vector3 vec3, Transform tran)
    {
        int[] sign = new int[2];
        int wah = 0;
        ArrayGrid = new BaseGrid[ver, hor];
        for (int i = 0; i < ver; i++)
        {

            sign[0] = i;
            if (i % 2 == 0)
            {
                wah = 0;
            }
            else
            {
                wah = 1;
            }
            for (int j = 0; j < hor; j++)
            {
                sign[1] = j;
                if (wah == 0)
                {
                    ArrayGrid[i, j] = new BaseGrid(floor, material[wah], vec3, tran, sign);
                    wah = 1;
                }
                else if (wah == 1)
                {
                    ArrayGrid[i, j] = new BaseGrid(floor, material[wah], vec3, tran, sign);
                    wah = 0;
                }
                ArrayGrid[i, j].E_Grid_Type = E_MapGrid_Type.Type_default;
                vec3.x = vec3.x + 1;
            }
            vec3.x = 0;
            vec3.z = vec3.z + 1;
        }
    }
}


